package com.example.myapplication.rxjava;

import android.os.Bundle;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import com.orhanobut.logger.Logger;

import io.reactivex.Observable;
import io.reactivex.ObservableEmitter;
import io.reactivex.ObservableOnSubscribe;
import io.reactivex.Observer;
import io.reactivex.annotations.NonNull;
import io.reactivex.functions.Consumer;
import kotlin.ThrowsKt;

/**
 * 类描述:
 * 创建人:   tangchao$
 * 创建时间: 2021/9/2$ 8:30 AM$
 * 联系方式: 419704299@qq.com
 * 修改人:   tangchao$
 * 修改时间: 2021/9/2$ 8:30 AM$
 * 修改备注:  [说明本次修改内容]
 */
public class RxjavaActivity02 extends AppCompatActivity {
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        test1();
        test2();
    }

    private void test2() {
        Observable.concatArrayDelayError(Observable.just(new Throwable()),
                Observable.just(1))
                .subscribe();

    }

    private void test1() {
        Observable.concatArray(Observable.create(new ObservableOnSubscribe<Integer>() {
            @Override
            public void subscribe(@NonNull ObservableEmitter<Integer> emitter) throws Exception {
                emitter.onNext(11);
                emitter.onError(new Throwable());
            }
        }), Observable.just(1, 2, 3)).subscribe(new Consumer<Object>() {
            @Override
            public void accept(Object o) throws Exception {

            }
        });
    }
}
